<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 

<style type="text/css">
    	div.col-sm-3.text-left,div.col-sm-5.text-left,div.col-sm-10.text-left{
    	    color:#949494;
    	}
    	label.checkLong *{
    		vertical-align: middle;
    		margin: 0px;
    	}
</style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    
    <section class="content-header">
        <h1 >修改</h1>
         <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
             <li><a href="#">交易</a></li>
              <li><a href="#">药品短缺管理</a></li>
              <li><a href="#">药品短缺查看</a></li>
        </ol> 
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <!-- form start -->
            <form role="form" id="form" class="form-horizontal"  method="post">
            	<input hidden id='shortmedicine_id' name='shortmedicine_id' value='<c:out value="${info.shortmedicine_id}" />' >
            	
                <div class="box-body">
	                <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right"><span class="required">*</span>通用名：</label>
                        <div class="col-sm-4 text-left">
	                            <input type="text" class="form-control" id="drug_name" name="drug_name" readonly="readonly" value="${info.drug_name}" placeholder="通用名" />
	                        </div>
	                         <label class="col-sm-2 text-right"><span class="required">*</span>剂型：</label>
                        <div class="col-sm-4 text-left">
	                           <input type="text" class="form-control" id="form_name" name="form_name" readonly="readonly" value="${info.form_name}" placeholder="剂型" />
	                        </div>
	                 </div>
	                 <div class="line"></div>
	                  <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right"><span class="required">*</span>规格：</label>
                        <div class="col-sm-4 text-left">
	                           <input type="text" class="form-control" id="spec_name" name="spec_name" readonly="readonly" value="${info.spec_name}" placeholder="规格" />
	                        </div>
	                        <label class="col-sm-2 text-right"><span class="required">*</span>转换系数：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control"  id="factor" name="factor" placeholder="转换系数" type="text" readonly="readonly" value="${info.factor }" />
                        </div>	                        	                       
	                  </div>
	                   
	                    <div class="line"></div>
	                    
	                  <div class="form-group form-group-xs">
	                  		 <label class="col-sm-2 text-right"><span class="required">*</span>单位：</label>
                        <div class="col-sm-4 text-left">
	                           <input type="text" class="form-control" id="unit_name" name="unit_name" readonly="readonly" value="${info.unit_name}" placeholder="单位" />
	                        </div>	               
	                       <label class="col-sm-2 text-right"><span class="required">*</span>生产企业：</label>
                        <div class="col-sm-4 text-left">
	                           <input type="text" class="form-control" id="comp_name" name="comp_name" readonly="readonly" value="${info.comp_name}" placeholder="生产企业" />
	                        </div>
	                        </div>
	                        
	                         <div class="line"></div>
	                    <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right"><span class="required">*</span>药物属性：</label>
                        <div class="col-sm-4 text-left">
	                                 <select class="form-control" id="drug_attr" name="drug_attr" disabled="disabled">
                                <option value="">请选择</option>
                                <option value="1" ${ info.drug_attr == 1 ? "selected='selected'" : "" } >国家基本药物</option>
                                <option value="2" ${ info.drug_attr == 2 ? "selected='selected'" : "" } >省增补基本药物</option>
                                <option value="3" ${ info.drug_attr == 3 ? "selected='selected'" : "" } >其他</option> 
                            </select>
	                            </div>
	                             <label class="col-sm-2 text-right"><span class="required">*</span>国药准字：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="drug_medicine" name="drug_medicine" placeholder="国药准字" type="text" readonly="readonly" value="${info.drug_medicine }">
                    	</div>
	                   </div>
	                        <div class="line"></div>
	                        <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>年需求量：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="need_count" name="need_count" placeholder="年需求量" type="text" maxlength="10" value="${info.need_count }">
                        </div>
                        <label class="col-sm-2 text-right"><span class="required">*</span>短缺时间（月）：</label>
                        <div class="col-sm-4 text-left">
                         	<input class="form-control" type="text" id="shortDate" name="shortDate" placeholder="yyyy-MM" data-provide="datepicker" data-date-fmt="yyyy-MM" value="${info.short_date }" />
                        </div>
                 </div>
	                        
	                        
	                         <div class="line"></div>
	                    
	                  <div class="form-group form-group-xs">
	                         <label class="col-sm-2 text-right"><span class="required">*</span>短缺类型：</label>
                        <div class="col-sm-4 text-left">
	                           <select class="form-control" id="short_type" name="short_type">
                                <option value="">请选择</option>
                                <option value="1" ${ info.short_type == 1 ? "selected='selected'" : "" } >价格偏低</option>
                                <option value="2" ${ info.short_type == 2 ? "selected='selected'" : "" } >原材料短缺</option>
                                <option value="3" ${ info.short_type == 3 ? "selected='selected'" : "" } >用量少</option>
                                <option value="9" ${ info.short_type == 9 ? "selected='selected'" : "" } >其他</option>
                            </select>
	                        </div>	                   
	                  </div>
                  <div class="line"></div>
	                   <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>短缺原因：</label>
                        <div class="col-sm-10 text-left">
                            <textarea class="form-control" id="shortage_reason" name="shortage_reason" maxlength="2000" rows="3" >${info.shortage_reason }</textarea>
                        </div>  
	                   </div>
                       <div class="line"></div>
	                   <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right"><span class="required">*</span>申报备注<spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-9 text-left">
	                        	   <textarea rows="3" class="form-control" id="remark" name="remark" maxlength="2000" >${info.remark }</textarea> 
	                        </div>
	                   </div>		                  
                </div>
                
                
                
               <div class="box-footer text-center">
               		 <button type="button" onclick="submitUpdate();" class="btn btn-success btn-sm">修&nbsp;改</button>
                    <button type="button" onclick="back();" class="btn btn-danger btn-sm">返&nbsp;回</button>
               </div>
            </form>
        </div>
    </section>
</body>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
/*
	$(function(){
		$("input[name='isLongterm']").on('change',function(e){
			var tag = $(this).val();
			if(tag==0){
				$('#shortTable').show();
			}else{
				$('#shortTable').hide();
			}
		});
	})
	*/
		function submitUpdate(){
			if(!valid()){
				return;
			}
	 		$.HN.message.confirm('确定修改吗？', '', '').on(function (e) {
    			if (e) {
    				var remark = $("#remark").val();
    				
    				var short_type = $("#short_type").val();
    				var drug_name = $("#drug_name").val();
    				var form_name = $("#form_name").val();
    				var spec_name = $("#spec_name").val();
    				var factor = $("#factor").val();
    				var unit_name = $("#unit_name").val();
    				var comp_name = $("#comp_name").val();    				
    				var upd_user = $("#upd_user").val();
    				var drug_attr = $("#drug_attr").val();
    				var drug_medicine = $("#drug_medicine").val();
    				var need_count = $("#need_count").val();
    				var shortDate = $("#shortDate").val();    				
    				var shortage_reason = $("#shortage_reason").val();    				
    				var shortmedicine_id = $("#shortmedicine_id").val();
    				
    				var postData ={
    						drug_name:drug_name,
    						short_type:short_type,
    						remark:remark,
    						form_name:form_name,
    						spec_name:spec_name,
    						factor:factor,
    						unit_name:unit_name,
    						comp_name:comp_name,    						
    						upd_user:upd_user,
    						drug_attr:drug_attr,
    						drug_medicine:drug_medicine,
    						need_count:need_count,
    						short_date:shortDate,
    						shortage_reason:shortage_reason,
    						shortmedicine_id:shortmedicine_id
    				};
    				
    	    		$.post("${ctx}/DrugShortage/updateShortageBySMI.html",postData, function(result) {
    	    			if (result.success) {
    	    				$.HN.message.alert("操作成功！", "消息", "success");
    	    				window.location.href="${ctx}/DrugShortage/toList.html";
    	    			} else {
    	    				$.HN.message.alert("操作失败！", "消息", "error");
    	    				window.location.href="${ctx}/DrugShortage/toList.html";
    	    			}
    	    		}, "json")
    			}
    		}); 
		}
	
	function valid(){
		var remark =$('#remark').val();
		if(remark==null || remark==""){
			 top.$.alert('请输入申报备注','warn');
			 $('#remark').focus();
			 return false;
		}
		
       /*  var drug_name = $.trim($("#drug_name").val());
        if (drug_name == null || drug_name == "") {
              $.alert("请输入通用名！",  "warn");
                return false;
        }
        $("#drug_name").val(drug_name);
        
        var form_name = $.trim($("#form_name").val());
        if (form_name == null || form_name == "") {
              $.alert("请输入剂型！",  "warn");
                return false;
        }
        $("#form_name").val(form_name);
        
        var spec_name = $.trim($("#spec_name").val());
        if (spec_name == null || spec_name == "") {
              $.alert("请输入规格！",  "warn");
                return false;
        }
        $("#spec_name").val(spec_name);
        
        var factor = $.trim($("#factor").val());
        if (factor == null || factor == "") {
              $.alert("请输入转换系数！",  "warn");
                return false;
        }
        $("#factor").val(factor);
        
        var unit_name = $.trim($("#unit_name").val());
        if (unit_name == null || unit_name == "") {
              $.alert("请输入单位！",  "warn");
                return false;
        }
        $("#unit_name").val(unit_name);
        
        var comp_name = $.trim($("#comp_name").val());
        if (comp_name == null || comp_name == "") {
              $.alert("请输入生产企业！",  "warn");
                return false;
        }
        $("#comp_name").val(comp_name);
        
        var drug_attr = $.trim($("#drug_attr").val());
        if (drug_attr == null || drug_attr == "") {
              $.alert("请输入药物属性！",  "warn");
                return false;
        }
        $("#drug_attr").val(drug_attr);
        
        var drugMedicine = $.trim($("drugMedicine").val());
        if (drugMedicine == null || drugMedicine == "") {
              $.alert("请输入国药准字！",  "warn");
                return false;
        }
        $("#drugMedicine").val(drugMedicine); */
        
        var need_count = $.trim($("#need_count").val());
        if (need_count == null || need_count == "") {
              $.alert("请输入年需求量！",  "warn");
                return false;
        }
        $("#need_count").val(need_count);
        
        var shortDate = $.trim($("#shortDate").val());
        if (shortDate == null || shortDate == "") {
              $.alert("请选择短缺时间！",  "warn");
                return false;
        }
        $("#shortDate").val(shortDate);
        
        var shortage_reason = $.trim($("#shortage_reason").val());
        if (shortage_reason == null || shortage_reason == "") {
              $.alert("请输入短缺原因！",  "warn");
                return false;
        }
        $("#shortage_reason").val(shortage_reason);
        

        
        var short_type = $.trim($("#short_type").val());
        if (short_type == null || short_type == "") {
              $.alert("请输入短缺类型！",  "warn");
               return false;
        }
        $("#short_type").val(short_type);
        
        return true;
	}
	//返回
	function back(){
	   	window.location.href="${ctx}/DrugShortage/toList.html";
	}

</script>
</html>